import { clone } from './util';

/**
 * 所有AST类的基类
 */
export abstract class Sql {
  abstract readonly $type: SQL_SYMBOLE;
  /**
   * 克隆自身
   */
  clone(): this {
    return clone(this);
  }
}

export enum SQL_SYMBOLE {
  DECLARE = 'DECLARE',
  EXPRESSION = 'EXPRESSION',
  CREATE_TABLE_COLUMN = 'CREATE_TABLE_COLUMN',
  STAR = 'STAR',
  RAW = 'RAW',
  STATEMENT = 'STATEMENT',
  // ANY = '*',
  INVOKE_ARGUMENT_LIST = 'INVOKE_ARGUMENT_LIST',
  EXECUTE_ARGUMENT_LIST = 'EXECUTE_ARGUMENT_LIST',
  VARAINT_DECLARE = 'VARAINT_DECLARE',
  TABLE_VARIANT_DECLARE = 'TABLE_VARIANT_DECLARE',
  IDENTIFIER = 'IDENTIFIER',
  IDENTITY_VALUE = 'IDENTITY_VALUE',
  VIRTUAL_EXPRESSION = 'STANDARD_EXPRESSION',
  SCALAR_FUNCTION_INVOKE = 'SCALAR_FUNCTION_INVOKE',
  TABLE_FUNCTION_INVOKE = 'TABLE_FUNCTION_INVOKE',
  LITERAL = 'LITERAL',
  SORT = 'SORT',
  JOIN = 'JOIN',
  UNION = 'UNION',
  WHEN = 'WHEN',
  CASE = 'CASE',
  DOCUMENT = 'DOCUMENT',
  WITH = 'WITH',
  GROUP_EXPRESSION = 'GROUP_EXPRESSION',
  NAMED_SELECT = 'NAMED_SELECT',
  WITH_SELECT = 'WITH_SELECT',
  OPERATION = 'OPERATION',
  VALUED_SELECT = 'VALUED_SELECT',
  PRIMARY_KEY = 'CREATE_TABLE_PRIMARY_KEY',
  FOREIGN_KEY = 'FOREIGN_KEY',
  ALTER_TABLE_DROP_MEMBER = 'ALTER_TABLE_DROP_COLUMN',
  ALTER_TABLE_DROP_CONSTRAINT = 'ALTER_TABLE_DROP_CONSTRAINT',
  CHECK_CONSTRAINT = 'CHECK_CONSTRAINT',
  UNIQUE_KEY = 'UNIQUE_KEY',
  PROCEDURE_PARAMETER = 'PROCEDURE_PARAMETER',
  FUNCTION_PARAMETER = 'FUNCTION_PARAMETER',
  ALTER_TABLE_COLUMN = 'ALTER_TABLE_COLUMN',
  CONDITION = 'CONDITION',
  PARAMETER = 'PARAMETER',
  /**
   * 表
   */
  TABLE = 'TABLE',
  /**
   * 字段
   */
  FIELD = 'FIELD',
  /**
   * 函数
   */
  FUNCTION = 'FUNCITON',

  /**
   * 序列
   */
  SEQUENCE = 'SEQUENCE',
  // /**
  //  * 标量函数
  //  */
  // SCALAR_FUNCTION ='SCALAR_FUNCTION',
  // /**
  //  * 表值函数
  //  */
  // TABLE_FUNCTION = 'TABLE_FUNCTION',
  /**
   * 存储过程
   */
  PROCEDURE = 'PROCEDURE',
  /**
   * 内建标识
   */
  BUILT_IN = 'BUILT_IN',
  /**
   * 别名
   */
  ALIAS = 'ALIAS',
  /**
   * 列
   */
  SELECT_COLUMN = 'SELECT_COLUMN',
  /**
   * 变量
   */
  VARIANT = 'VARIANT',
  /**
   * 表变量
   */
  TABLE_VARIANT = 'TABLE_VARIANT',
  /**
   * 对象
   */
  OBJECT = 'OBJECT',
  ROWSET = 'ROWSET',

  ROW_NUMBER = 'ROW_NUMBER'
}
